from threading import Thread
import time
from multiprocessing import process

#第一问，实现一个多线程程序
def one(num):
    for i in range(num):
        print(f"I am {i}")
        time.sleep(0.5)

def two(num):
    for i in range(num):
        print(f"you are {i}")
        time.sleep(0.5)

def main():
    t_one = Thread (target = one, args = (5, ))
    t_two = Thread (target = two, args = (6, ))
    t_one.start()
    t_two.start()

if __name__ == '__main__':
    main()

#第二部，将多线程改为多进程
def one(num):
    for i in range(num):
        print(f"I am {i}")


def two(num):
    for i in range(num):
        print(f"you are {i}")


def main():
    p_one = process (target = one, args = (5, ))
    p_two = process(target = two, args = (6, ))
    p_one.start()
    p_two.start()